home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / tsetguid.zip / TEA / SET / SAMPLE / MLISTURL.JAV < prev    next >
Text File  |  1997-02-27  |  3KB  |  96 lines

  1. /*
  2.  * Copyright (c) 1996-1997, InetSoft Technology Corp, All Rights Reserved.
  3.  *
  4.  * The software and information contained herein are copyrighted and 
  5.  * proprietary to InetSoft Technology Corp. This software is furnished 
  6.  * pursuant to a written license agreement and may be used, copied, 
  7.  * transmitted, and stored only in accordance with the terms of such 
  8.  * license and with the inclusion of the above copyright notice. Please 
  9.  * refer to the file "COPYRIGHT" for further copyright and licensing 
  10.  * information. This software and information or any other copies 
  11.  * thereof may not be provided or otherwise made available to any 
  12.  * other person. 
  13.  */
  14. package tea.set.sample;
  15.  
  16. import tea.set.*;
  17. import java.applet.*;
  18. import java.awt.*;
  19. import java.awt.event.*;
  20. import java.net.*;
  21. import java.util.*;
  22.  
  23. /**
  24.  * This is a demostration applet, which extends MultiListA applet
  25.  * to provide support for attaching URL to list items.
  26.  *
  27.  * @see MultiList
  28.  * @see MultiListA
  29.  * @version 1.3, 01/31/97
  30.  * @author InetSoft Technology Corp
  31.  */
  32. public class MListURL extends MultiListA {
  33.    public void init() {
  34.       super.init();
  35.       String str;
  36.  
  37.       // fetch the URL parameters
  38.       for(int i = 0; (str = getParameter("ROW"+i)) != null; i++) {
  39.      if((str = getParameter("URL"+i)) == null) {
  40.         urls.addElement(null);
  41.      }
  42.      else {
  43.         try {
  44.            urls.addElement(new URL(getDocumentBase(), str));
  45.         }
  46.         catch(Exception e) {
  47.            e.printStackTrace();
  48.         }
  49.      }
  50.       }
  51.       
  52.       MultiList list = (MultiList) getWidget();
  53.       list.addActionListener(new MListAction());
  54.       list.addMouseListener(new MListMouse());
  55.       list.addMouseMotionListener(new MListMouseMotion());
  56.    }
  57.    
  58.    // display URL at double mouse click inside an item
  59.    class MListAction implements ActionListener {
  60.       public void actionPerformed(ActionEvent e) {
  61.      MultiList list = (MultiList) e.getSource();
  62.      int r = list.getSelectedRow();
  63.      
  64.      if(r >= 0 && urls.elementAt(r) != null) {
  65.         getAppletContext().showDocument((URL) urls.elementAt(r));
  66.      }
  67.       }
  68.    }
  69.  
  70.    // display urs string associated with a row if the mouse pointer is
  71.    // inside the row
  72.    class MListMouse extends MouseAdapter {
  73.       // clear applet message on mouse exit
  74.       public void mouseExited(MouseEvent e) {
  75.      showStatus("");
  76.       }
  77.    }
  78.       
  79.    class MListMouseMotion extends MouseMotionAdapter {
  80.       public void mouseMoved(MouseEvent e) {
  81.      MultiList list = (MultiList) e.getSource();
  82.      int row = list.locateRow(e.getX(), e.getY());
  83.      
  84.      if(row >= 0 && urls.elementAt(row) != null) {
  85.         showStatus(urls.elementAt(row).toString());
  86.      }
  87.      else {
  88.         showStatus("");
  89.      }
  90.       }
  91.       
  92.    }
  93.    
  94.    private Vector urls = new Vector();
  95. }
  96.